Skip to content

feat(blog): giscus 기반 댓글 기능#79

Merged
SimYunSup merged 7 commits into
mainfrom
fix/issue-57
Jun 27, 2026
Merged

feat(blog): giscus 기반 댓글 기능#79
SimYunSup merged 7 commits into
mainfrom
fix/issue-57

Conversation

@SimYunSup

@SimYunSup SimYunSup commented Jun 25, 2026

Copy link
Copy Markdown
Member

개요

블로그 글 상세 페이지에 giscus 기반 댓글 기능을 추가합니다. (이슈 #57)

변경 내용

  • 공식 @giscus/react로 댓글 위젯 렌더링
  • 글 slug = "블로그" 카테고리 Discussion 번호라 mapping=number로 원본 토론에 연결
  • 다크모드 토큰과 연동(theme), 언어는 ko
  • giscus 설정값(repo·category·id)은 공개돼도 되는 값이라 src/constants/giscus.ts에 하드코딩

- src/constants/giscus.ts: 설정값 상수 분리(VITE_GISCUS_* override) + buildGiscusAttributes() 순수 함수
- src/components/Giscus.tsx: useEffect로 client.js 동적 주입, useTheme 다크모드 연동(postMessage), pathname 매핑
- src/routes/blog.$slug.tsx: 글 하단에 Giscus 위젯 렌더(key=slug로 글 전환 시 재마운트)
- src/constants/giscus.test.ts: 속성/매핑/언어/옵션/테마 단위 테스트
코드리뷰 반영:
- 글마다 재마운트(key={slug})하면 client.js가 매번 재실행돼 window message
  리스너가 누적되던 문제 → Giscus를 한 번만 마운트하고 글·테마 전환은
  iframe에 setConfig 메시지로 갱신. pathname→term 계산은 client.js와 동일.
- iframe load 시점에 현재 설정을 재전송해, 로딩 중 테마 토글이 유실되던
  레이스를 보정(MutationObserver로 iframe 감지 → load 핸들러).
- dev 모드에서 repoId/categoryId 미설정 시 console.warn 가드 추가.
- pathnameToTerm 순수 함수 분리 + 단위 테스트 추가.
- 장황한 주석 정리.
@SimYunSup SimYunSup requested a review from a team as a code owner June 25, 2026 23:56
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Ready
View logs
daleui b8a866c Commit Preview URL Jun 26 2026, 09:45 AM

@SimYunSup SimYunSup marked this pull request as draft June 25, 2026 23:56
- import 정렬(sort-imports): GISCUS_* 를 앞으로
- 렌더 중 ref 변경(react-hooks) 해소: configRef 갱신을 effect 안으로 이동
- AI 티 나는 주석 정리
@SimYunSup SimYunSup closed this Jun 26, 2026
@SimYunSup SimYunSup reopened this Jun 26, 2026
deploy/preview 워크플로우의 bun run build에 giscus repo-id·category-id를
GitHub Actions Variables로 넘긴다. 비밀값이 아니라 vars 사용. 관리자가
Variables만 채우면 프로덕션·프리뷰 빌드에 반영된다.
@SimYunSup SimYunSup changed the title feat(blog): giscus 기반 댓글 기능 (이슈 #57) feat(blog): giscus 기반 댓글 기능 Jun 26, 2026
블로그 글은 DaleStudy/daleui "블로그" 카테고리 Discussion에서 오고 slug가 곧
discussion 번호다. 기존 글타래에 댓글이 달리도록 다음을 바꿨다.

- repo: DaleStudy/daleui.com → DaleStudy/daleui (원본 discussion이 있는 곳)
- mapping: pathname → number, term = slug(번호)
- repo-id/category-id 기본값을 daleui "블로그" 카테고리 공개값으로 설정
- Giscus는 term(번호) prop을 받아 setConfig로 number를 전송
- pathnameToTerm 제거, 테스트 갱신
@SimYunSup SimYunSup marked this pull request as ready for review June 26, 2026 03:34
Comment thread src/routes/blog.$slug.tsx
Comment on lines +157 to +159
<Box as="section" aria-label="댓글" className={css({ mt: "48" })}>
<Giscus term={slug} />
</Box>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giscus component lib를 사용하시는줄 알았는데 직접 구현하셨네요 특별한 이유가 있을까요?

https://github.com/giscus/giscus-component

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아, 예전에 만들었던 기억에 의존하다보니 있다는걸 몰랐네요 😅

리뷰 피드백 반영. 스크립트 주입·iframe 생명주기·테마/글 변경 시
setConfig 전달을 직접 재구현하던 컴포넌트를 공식 @giscus/react 래퍼로
교체. buildGiscusAttributes 등 불필요해진 코드 제거.
@SimYunSup SimYunSup requested a review from hyoseong1994 June 27, 2026 00:02

@hyoseong1994 hyoseong1994 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

@SimYunSup SimYunSup merged commit b99d83c into main Jun 27, 2026
4 checks passed
@SimYunSup SimYunSup deleted the fix/issue-57 branch June 27, 2026 00:08
@SimYunSup SimYunSup mentioned this pull request Jun 28, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants